
<!DOCTYPE HTML>
<html lang="zh-hans" >
<head>
    <meta charset="UTF-8">
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>2.4：资源管理 · 《Flutter实战》</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="baidu-site-verification" content="Y34sAqDKUH"/>
    <meta name="theme-color" content="#ffffff">
    <!--<meta name="description" content="">-->
    <meta name="description" content="《Flutter实战》是Flutter中文网（https://flutterchina.club）开源的电子书，旨在帮助开发者系统化的了解并学习Flutter。">
    <meta name="keywords" content="flutter实战,flutter书籍,flutter电子书,flutter中文网 ">
    <meta name="generator" content="GitBook 3.2.3">
    
    <meta name="author" content="wendux 824783146@qq.com">
    
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/style.css">

    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-prism/prism.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.css">
    
    
    
    <link rel="stylesheet" href="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/website.css">
    
    
    

    

    
        
    
        
    
        
    
        
    
        
    

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://pcdn.flutterchina.club/gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="https://pcdn.flutterchina.club/gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="flutter_app_debug.html" />
    
    
    <link rel="prev" href="flutter_package_mgr.html" />
    

    <style>
        .pull-right > i {
            font-size: 25px;
            color: #777 !important;
            cursor: pointer;

        }

        .pull-right > i:hover {
            color: #777 !important;
        }

        body {
            font-size: 15px !important;
        }

        a[href='../todo.html'], a[href='todo.html'] {
            color: #888 !important;
        }

        .copyright {
            text-align: center;
            margin: 80px 16px 8px 16px;
            padding-top: 16px;
            border-top: #eee 1px solid;
            color: grey;
            font-size: .9em;
        }

        .f-links a{
            text-decoration: underline;
            color: dodgerblue !important;
        }

        .f-links a:hover{
            opacity: .8 !important;
        }

        /*.ad {*/
            /*color: white;*/
            /*text-align: center;*/
            /*background: url(https://img.alicdn.com/tfs/TB1Huu7vMmTBuNjy1XbXXaMrVXa-2880-400.png);*/
            /*background-size: cover;*/
            /*cursor: pointer;*/
            /*margin-bottom: 30px;*/
            /*padding: 18px*/
        /*}*/

        /*.ad:hover {*/
            /*opacity: .8;*/
        /*}*/

        .buy-btn {
            text-decoration: none !important;
            padding: 8px 18px;
            border: #268bd2 1px solid !important;
            display: inline-block !important;
            border-radius: 25px;
            color: #268bd2;
            margin-top: 10px;
        }

        .buy-btn:hover {
            transition: all ease 200ms;
            box-shadow: #555 2px 5px 10px;
            background: #eee;
            color: dodgerblue !important;
        }

        .maoyun{
            padding-top: 5px;
        }


    </style>
</head>
<body>
<!--<div id="ad" style="display: none">-->
<!--<div class="ad ad0"-->
<!--onclick="_track('aliyun','https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.3em; padding-right: 120px; position: relative; top: 12px">阿里云新春特惠</div>-->
<!--<div style="color:orange; font-size: 13px">限时红包 最高￥<span style="font-size: 40px">1888</span></div>-->
<!--</div>-->
<!--<div class="ad ad1"-->
<!--onclick="_track('aliyun-puhui','https://promotion.aliyun.com/ntms/act/qwbk.html?spm=5176.11533457.1089570.10.74e877e33jtaGy&userCode=8hhi4dts')">-->
<!--<div style="font-size: 1.5em;">阿里云全民云计算-新春特惠</div>-->
<!--<div style="color:orange; font-size: 18px;padding-top: 4px;">普惠上云，云服务器1核1G仅需293元/年</div>-->
<!--</div>-->
<!--</div>-->

<div class="ad"  style="text-align:center; padding-bottom:30px; display: none"><a href="https://item.jd.com/12816296.html" onclick="buy('img')" title='点击购买' target="_blank"><img style="height:250px;box-shadow: #aaa 5px 5px 10px;" src="https://pcdn.flutterchina.club/imgs/book.png"/></a>  <br/> <a class="buy-btn" onclick="buy('img')" href="https://item.jd.com/12816296.html" title='点击购买' target="_blank"> 购买实体书 </a></div>


<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://flutterchina.club" target="_blank" class="custom-link"><div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div></a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../intro.html">
            
                <a href="../intro.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">入门篇</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    第一章：起步
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="../chapter1/mobile_development_intro.html">
            
                <a href="../chapter1/mobile_development_intro.html">
            
                    
                    1.1：移动开发技术简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.2" data-path="../chapter1/flutter_intro.html">
            
                <a href="../chapter1/flutter_intro.html">
            
                    
                    1.2：初识Flutter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="../chapter1/install_flutter.html">
            
                <a href="../chapter1/install_flutter.html">
            
                    
                    1.3：搭建Flutter开发环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="../chapter1/dart.html">
            
                <a href="../chapter1/dart.html">
            
                    
                    1.4：Dart语言简介
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="./">
            
                <a href="./">
            
                    
                    第二章：第一个Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="first_flutter_app.html">
            
                <a href="first_flutter_app.html">
            
                    
                    2.1：计数器示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="flutter_router.html">
            
                <a href="flutter_router.html">
            
                    
                    2.2：路由管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="flutter_package_mgr.html">
            
                <a href="flutter_package_mgr.html">
            
                    
                    2.3：包管理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.2.4" data-path="flutter_assets_mgr.html">
            
                <a href="flutter_assets_mgr.html">
            
                    
                    2.4：资源管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="flutter_app_debug.html">
            
                <a href="flutter_app_debug.html">
            
                    
                    2.5：调试Flutter APP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="thread_model_and_error_report.html">
            
                <a href="thread_model_and_error_report.html">
            
                    
                    2.6：Dart线程模型及异常捕获
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    第三章：基础组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../chapter3/flutter_widget_intro.html">
            
                <a href="../chapter3/flutter_widget_intro.html">
            
                    
                    3.1：Widget简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../chapter3/state_manage.html">
            
                <a href="../chapter3/state_manage.html">
            
                    
                    3.2：状态管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../chapter3/text.html">
            
                <a href="../chapter3/text.html">
            
                    
                    3.3：文本、字体样式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.4" data-path="../chapter3/buttons.html">
            
                <a href="../chapter3/buttons.html">
            
                    
                    3.4：按钮
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.5" data-path="../chapter3/img_and_icon.html">
            
                <a href="../chapter3/img_and_icon.html">
            
                    
                    3.5：图片和Icon
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.6" data-path="../chapter3/radio_and_checkbox.html">
            
                <a href="../chapter3/radio_and_checkbox.html">
            
                    
                    3.6：单选框和复选框
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.7" data-path="../chapter3/input_and_form.html">
            
                <a href="../chapter3/input_and_form.html">
            
                    
                    3.7：输入框和表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.8" data-path="../chapter3/progress.html">
            
                <a href="../chapter3/progress.html">
            
                    
                    3.8：进度指示器
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    第四章：布局类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../chapter4/intro.html">
            
                <a href="../chapter4/intro.html">
            
                    
                    4.1：布局类组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../chapter4/row_and_column.html">
            
                <a href="../chapter4/row_and_column.html">
            
                    
                    4.2：线性布局（Row、Column）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.3" data-path="../chapter4/flex.html">
            
                <a href="../chapter4/flex.html">
            
                    
                    4.3：弹性布局（Flex）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.4" data-path="../chapter4/wrap_and_flow.html">
            
                <a href="../chapter4/wrap_and_flow.html">
            
                    
                    4.4：流式布局（Wrap、Flow）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.5" data-path="../chapter4/stack.html">
            
                <a href="../chapter4/stack.html">
            
                    
                    4.5：层叠布局（Stack、Positioned）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.6" data-path="../chapter4/alignment.html">
            
                <a href="../chapter4/alignment.html">
            
                    
                    4.6：对齐与相对定位（Align）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    第五章：容器类组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.5.1" data-path="../chapter5/padding.html">
            
                <a href="../chapter5/padding.html">
            
                    
                    5.1：填充（Padding）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.2" data-path="../chapter5/constrainedbox_and_sizebox.html">
            
                <a href="../chapter5/constrainedbox_and_sizebox.html">
            
                    
                    5.2：尺寸限制类容器（ConstrainedBox等）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.3" data-path="../chapter5/decoratedbox.html">
            
                <a href="../chapter5/decoratedbox.html">
            
                    
                    5.3：装饰容器（DecoratedBox）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.4" data-path="../chapter5/transform.html">
            
                <a href="../chapter5/transform.html">
            
                    
                    5.4：变换（Transform）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.5" data-path="../chapter5/container.html">
            
                <a href="../chapter5/container.html">
            
                    
                    5.5：Container容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.6" data-path="../chapter5/material_scaffold.html">
            
                <a href="../chapter5/material_scaffold.html">
            
                    
                    5.6：Scaffold、TabBar、底部导航
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5.7" data-path="../chapter5/clip.html">
            
                <a href="../chapter5/clip.html">
            
                    
                    5.7：剪裁（Clip）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    第六章：可滚动组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.6.1" data-path="../chapter6/intro.html">
            
                <a href="../chapter6/intro.html">
            
                    
                    6.1：可滚动组件简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.2" data-path="../chapter6/single_child_scrollview.html">
            
                <a href="../chapter6/single_child_scrollview.html">
            
                    
                    6.2：SingleChildScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.3" data-path="../chapter6/listview.html">
            
                <a href="../chapter6/listview.html">
            
                    
                    6.3：ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.4" data-path="../chapter6/gridview.html">
            
                <a href="../chapter6/gridview.html">
            
                    
                    6.4：GridView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.5" data-path="../chapter6/custom_scrollview.html">
            
                <a href="../chapter6/custom_scrollview.html">
            
                    
                    6.5：CustomScrollView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6.6" data-path="../chapter6/scroll_controller.html">
            
                <a href="../chapter6/scroll_controller.html">
            
                    
                    6.6：滚动监听及控制（ScrollController）
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    第七章：功能型组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.7.1" data-path="../chapter7/willpopscope.html">
            
                <a href="../chapter7/willpopscope.html">
            
                    
                    7.1：导航返回拦截（WillPopScope）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.2" data-path="../chapter7/inherited_widget.html">
            
                <a href="../chapter7/inherited_widget.html">
            
                    
                    7.2：数据共享（InheritedWidget）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.3" data-path="../chapter7/provider.html">
            
                <a href="../chapter7/provider.html">
            
                    
                    7.3： 跨组件状态共享（Provider）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.4" data-path="../chapter7/theme.html">
            
                <a href="../chapter7/theme.html">
            
                    
                    7.4：颜色和主题（Theme）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.5" data-path="../chapter7/futurebuilder_and_streambuilder.html">
            
                <a href="../chapter7/futurebuilder_and_streambuilder.html">
            
                    
                    7.5：异步UI更新（FutureBuilder、StreamBuilder）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7.6" data-path="../chapter7/dailog.html">
            
                <a href="../chapter7/dailog.html">
            
                    
                    7.6：对话框详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">进阶篇</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../chapter8/">
            
                <a href="../chapter8/">
            
                    
                    第八章：事件处理与通知
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../chapter8/listener.html">
            
                <a href="../chapter8/listener.html">
            
                    
                    8.1：原始指针事件处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../chapter8/gesture.html">
            
                <a href="../chapter8/gesture.html">
            
                    
                    8.2：手势识别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../chapter8/eventbus.html">
            
                <a href="../chapter8/eventbus.html">
            
                    
                    8.3：全局事件总线
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../chapter8/notification.html">
            
                <a href="../chapter8/notification.html">
            
                    
                    8.4：通知(Notification)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../chapter9/">
            
                <a href="../chapter9/">
            
                    
                    第九章：动画
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../chapter9/intro.html">
            
                <a href="../chapter9/intro.html">
            
                    
                    9.1：Flutter动画简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../chapter9/animation_structure.html">
            
                <a href="../chapter9/animation_structure.html">
            
                    
                    9.2：动画结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../chapter9/route_transition.html">
            
                <a href="../chapter9/route_transition.html">
            
                    
                    9.3：自定义路由过渡动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../chapter9/hero.html">
            
                <a href="../chapter9/hero.html">
            
                    
                    9.4：Hero动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../chapter9/stagger_animation.html">
            
                <a href="../chapter9/stagger_animation.html">
            
                    
                    9.5：交织动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../chapter9/animated_switcher.html">
            
                <a href="../chapter9/animated_switcher.html">
            
                    
                    9.6：通用“动画切换”组件（AnimatedSwitcher）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../chapter9/animated_widgets.html">
            
                <a href="../chapter9/animated_widgets.html">
            
                    
                    9.7：动画过渡组件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../chapter10/">
            
                <a href="../chapter10/">
            
                    
                    第十章：自定义组件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../chapter10/intro.html">
            
                <a href="../chapter10/intro.html">
            
                    
                    10.1：自定义组件方法简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../chapter10/combine.html">
            
                <a href="../chapter10/combine.html">
            
                    
                    10.2：组合现有组件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../chapter10/turn_box.html">
            
                <a href="../chapter10/turn_box.html">
            
                    
                    10.3：组合实例：TurnBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../chapter10/custom_paint.html">
            
                <a href="../chapter10/custom_paint.html">
            
                    
                    10.4：自绘组件（CustomPaint与Canvas）
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../chapter10/gradient_circular_progress_demo.html">
            
                <a href="../chapter10/gradient_circular_progress_demo.html">
            
                    
                    10.5：自绘实例：圆形渐变进度条(自绘)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../chapter11/">
            
                <a href="../chapter11/">
            
                    
                    第十一章：文件操作与网络请求
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../chapter11/file_operation.html">
            
                <a href="../chapter11/file_operation.html">
            
                    
                    11.1：文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../chapter11/http.html">
            
                <a href="../chapter11/http.html">
            
                    
                    11.2：Http请求-HttpClient
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../chapter11/dio.html">
            
                <a href="../chapter11/dio.html">
            
                    
                    11.3：Http请求-Dio package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../chapter11/download_with_chunks.html">
            
                <a href="../chapter11/download_with_chunks.html">
            
                    
                    11.4：实例：Http分块下载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../chapter11/websocket.html">
            
                <a href="../chapter11/websocket.html">
            
                    
                    11.5：WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../chapter11/socket.html">
            
                <a href="../chapter11/socket.html">
            
                    
                    11.6：使用Socket API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="../chapter11/json_model.html">
            
                <a href="../chapter11/json_model.html">
            
                    
                    11.7：Json转Dart Model类
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../chapter12/">
            
                <a href="../chapter12/">
            
                    
                    第十二章：包与插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../chapter12/develop_package.html">
            
                <a href="../chapter12/develop_package.html">
            
                    
                    12.1：开发package
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../chapter12/platform-channel.html">
            
                <a href="../chapter12/platform-channel.html">
            
                    
                    12.2：平台通道简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../chapter12/develop_plugin.html">
            
                <a href="../chapter12/develop_plugin.html">
            
                    
                    12.3：开发Flutter插件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../chapter12/android_implement.html">
            
                <a href="../chapter12/android_implement.html">
            
                    
                    12.4：插件开发：实现Android端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../chapter12/ios_implement.html">
            
                <a href="../chapter12/ios_implement.html">
            
                    
                    12.5：插件开发：实现IOS端API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="../chapter12/texture_platformview.html">
            
                <a href="../chapter12/texture_platformview.html">
            
                    
                    12.6：Texture和PlatformView
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../chapter13/">
            
                <a href="../chapter13/">
            
                    
                    第十三章：国际化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../chapter13/multi_languages_support.html">
            
                <a href="../chapter13/multi_languages_support.html">
            
                    
                    13.1：让App支持多语言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../chapter13/locallization_implement.html">
            
                <a href="../chapter13/locallization_implement.html">
            
                    
                    13.2：实现Localizations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../chapter13/intl.html">
            
                <a href="../chapter13/intl.html">
            
                    
                    13.3：使用Intl包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../chapter13/faq.html">
            
                <a href="../chapter13/faq.html">
            
                    
                    13.4：国际化常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../chapter14/">
            
                <a href="../chapter14/">
            
                    
                    第十四章：Flutter核心原理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../chapter14/flutter_ui_system.html">
            
                <a href="../chapter14/flutter_ui_system.html">
            
                    
                    14.1：Flutter UI系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../chapter14/element_buildcontext.html">
            
                <a href="../chapter14/element_buildcontext.html">
            
                    
                    14.2：Element和BuildContext
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="../chapter14/render_object.html">
            
                <a href="../chapter14/render_object.html">
            
                    
                    14.3：RenderObject与RenderBox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.4" data-path="../chapter14/flutter_app_startup.html">
            
                <a href="../chapter14/flutter_app_startup.html">
            
                    
                    14.4：Flutter从启动到显示
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="../chapter14/image_and_cache.html">
            
                <a href="../chapter14/image_and_cache.html">
            
                    
                    14.5：Flutter图片加载与缓存
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实例篇</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    第十五章：一个完整的Flutter应用
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../chapter15/intro.html">
            
                <a href="../chapter15/intro.html">
            
                    
                    15.1：应用简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../chapter15/code_structure.html">
            
                <a href="../chapter15/code_structure.html">
            
                    
                    15.2：APP代码结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.3" data-path="../chapter15/models.html">
            
                <a href="../chapter15/models.html">
            
                    
                    15.3：Model类定义
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.4" data-path="../chapter15/globals.html">
            
                <a href="../chapter15/globals.html">
            
                    
                    15.4：全局变量及共享状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.5" data-path="../chapter15/network.html">
            
                <a href="../chapter15/network.html">
            
                    
                    15.5：网络请求封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.6" data-path="../chapter15/entry.html">
            
                <a href="../chapter15/entry.html">
            
                    
                    15.6：App入口及首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.7" data-path="../chapter15/login_page.html">
            
                <a href="../chapter15/login_page.html">
            
                    
                    15.7：登录页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.8" data-path="../chapter15/language_and_theme_setting.html">
            
                <a href="../chapter15/language_and_theme_setting.html">
            
                    
                    15.8：多语言和多主题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="https://pcdn.flutterchina.club/gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    
    <a class="btn pull-right" aria-label="GitHub">
        <i class="fa fa-edit" title="编辑本文"></i>
    </a>
    <a class="btn pull-right" aria-label="GitHub" href="https://github.com/flutterchina/flutter-in-action">
        <i class="fa fa-github" title="查看本书开源项目"></i>
    </a>
    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >2.4：资源管理</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="24-&#x8D44;&#x6E90;&#x7BA1;&#x7406;">2.4 &#x8D44;&#x6E90;&#x7BA1;&#x7406;</h1>
<p>Flutter APP&#x5B89;&#x88C5;&#x5305;&#x4E2D;&#x4F1A;&#x5305;&#x542B;&#x4EE3;&#x7801;&#x548C; assets&#xFF08;&#x8D44;&#x6E90;&#xFF09;&#x4E24;&#x90E8;&#x5206;&#x3002;Assets&#x662F;&#x4F1A;&#x6253;&#x5305;&#x5230;&#x7A0B;&#x5E8F;&#x5B89;&#x88C5;&#x5305;&#x4E2D;&#x7684;&#xFF0C;&#x53EF;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x8BBF;&#x95EE;&#x3002;&#x5E38;&#x89C1;&#x7C7B;&#x578B;&#x7684;assets&#x5305;&#x62EC;&#x9759;&#x6001;&#x6570;&#x636E;&#xFF08;&#x4F8B;&#x5982;JSON&#x6587;&#x4EF6;&#xFF09;&#x3001;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x3001;&#x56FE;&#x6807;&#x548C;&#x56FE;&#x7247;&#xFF08;JPEG&#xFF0C;WebP&#xFF0C;GIF&#xFF0C;&#x52A8;&#x753B;WebP / GIF&#xFF0C;PNG&#xFF0C;BMP&#x548C;WBMP&#xFF09;&#x7B49;&#x3002;</p>
<h2 id="&#x6307;&#x5B9A;-assets">&#x6307;&#x5B9A; assets</h2>
<p>&#x548C;&#x5305;&#x7BA1;&#x7406;&#x4E00;&#x6837;&#xFF0C;Flutter&#x4E5F;&#x4F7F;&#x7528;<a href="https://www.dartlang.org/tools/pub/pubspec" target="_blank"><code>pubspec.yaml</code></a>&#x6587;&#x4EF6;&#x6765;&#x7BA1;&#x7406;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6240;&#x9700;&#x7684;&#x8D44;&#x6E90;&#xFF0C;&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;:</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">flutter</span><span class="token punctuation">:</span>
  <span class="token key atrule">assets</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> assets/my_icon.png
    <span class="token punctuation">-</span> assets/background.png
</code></pre>
<p><code>assets</code>&#x6307;&#x5B9A;&#x5E94;&#x5305;&#x542B;&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#xFF0C; &#x6BCF;&#x4E2A;asset&#x90FD;&#x901A;&#x8FC7;&#x76F8;&#x5BF9;&#x4E8E;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x8DEF;&#x5F84;&#x6765;&#x6807;&#x8BC6;&#x81EA;&#x8EAB;&#x7684;&#x8DEF;&#x5F84;&#x3002;asset&#x7684;&#x58F0;&#x660E;&#x987A;&#x5E8F;&#x662F;&#x65E0;&#x5173;&#x7D27;&#x8981;&#x7684;&#xFF0C;asset&#x7684;&#x5B9E;&#x9645;&#x76EE;&#x5F55;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x6587;&#x4EF6;&#x5939;&#xFF08;&#x5728;&#x672C;&#x793A;&#x4F8B;&#x4E2D;&#x662F;assets&#x6587;&#x4EF6;&#x5939;&#xFF09;&#x3002;</p>
<p>&#x5728;&#x6784;&#x5EFA;&#x671F;&#x95F4;&#xFF0C;Flutter&#x5C06;asset&#x653E;&#x7F6E;&#x5230;&#x79F0;&#x4E3A; <em>asset bundle</em> &#x7684;&#x7279;&#x6B8A;&#x5B58;&#x6863;&#x4E2D;&#xFF0C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x53EF;&#x4EE5;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x8BFB;&#x53D6;&#x5B83;&#x4EEC;&#xFF08;&#x4F46;&#x4E0D;&#x80FD;&#x4FEE;&#x6539;&#xFF09;&#x3002;</p>
<h2 id="asset-&#x53D8;&#x4F53;&#xFF08;variant&#xFF09;">Asset &#x53D8;&#x4F53;&#xFF08;variant&#xFF09;</h2>
<p>&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x652F;&#x6301;&#x201C;asset&#x53D8;&#x4F53;&#x201D;&#x7684;&#x6982;&#x5FF5;&#xFF1A;&#x4E0D;&#x540C;&#x7248;&#x672C;&#x7684;asset&#x53EF;&#x80FD;&#x4F1A;&#x663E;&#x793A;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x3002; &#x5728;<code>pubspec.yaml</code>&#x7684;assets&#x90E8;&#x5206;&#x4E2D;&#x6307;&#x5B9A;asset&#x8DEF;&#x5F84;&#x65F6;&#xFF0C;&#x6784;&#x5EFA;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F1A;&#x5728;&#x76F8;&#x90BB;&#x5B50;&#x76EE;&#x5F55;&#x4E2D;&#x67E5;&#x627E;&#x5177;&#x6709;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x7684;&#x4EFB;&#x4F55;&#x6587;&#x4EF6;&#x3002;&#x8FD9;&#x4E9B;&#x6587;&#x4EF6;&#x968F;&#x540E;&#x4F1A;&#x4E0E;&#x6307;&#x5B9A;&#x7684;asset&#x4E00;&#x8D77;&#x88AB;&#x5305;&#x542B;&#x5728;asset bundle&#x4E2D;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x5982;&#x679C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x76EE;&#x5F55;&#x4E2D;&#x6709;&#x4EE5;&#x4E0B;&#x6587;&#x4EF6;:</p>
<ul>
<li>&#x2026;/pubspec.yaml</li>
<li>&#x2026;/graphics/my_icon.png</li>
<li>&#x2026;/graphics/background.png</li>
<li>&#x2026;/graphics/dark/background.png</li>
<li>&#x2026;etc.</li>
</ul>
<p>&#x7136;&#x540E;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x4E2D;&#x53EA;&#x9700;&#x5305;&#x542B;:</p>
<pre class="language-"><code>flutter:
  assets:
    - graphics/background.png
</code></pre><p>&#x90A3;&#x4E48;&#x8FD9;&#x4E24;&#x4E2A;<code>graphics/background.png</code>&#x548C;<code>graphics/dark/background.png</code> &#x90FD;&#x5C06;&#x5305;&#x542B;&#x5728;&#x60A8;&#x7684;asset bundle&#x4E2D;&#x3002;&#x524D;&#x8005;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;<em>main asset</em> &#xFF08;&#x4E3B;&#x8D44;&#x6E90;&#xFF09;&#xFF0C;&#x540E;&#x8005;&#x88AB;&#x8BA4;&#x4E3A;&#x662F;&#x4E00;&#x79CD;&#x53D8;&#x4F53;&#xFF08;variant&#xFF09;&#x3002;</p>
<p>&#x5728;&#x9009;&#x62E9;&#x5339;&#x914D;&#x5F53;&#x524D;&#x8BBE;&#x5907;&#x5206;&#x8FA8;&#x7387;&#x7684;&#x56FE;&#x7247;&#x65F6;&#xFF0C;Flutter&#x4F1A;&#x4F7F;&#x7528;&#x5230;asset&#x53D8;&#x4F53;&#xFF08;&#x89C1;&#x4E0B;&#x6587;&#xFF09;&#xFF0C;&#x5C06;&#x6765;&#xFF0C;Flutter&#x53EF;&#x80FD;&#x4F1A;&#x5C06;&#x8FD9;&#x79CD;&#x673A;&#x5236;&#x6269;&#x5C55;&#x5230;&#x672C;&#x5730;&#x5316;&#x3001;&#x9605;&#x8BFB;&#x63D0;&#x793A;&#x7B49;&#x65B9;&#x9762;&#x3002;</p>
<h2 id="&#x52A0;&#x8F7D;-assets">&#x52A0;&#x8F7D; assets</h2>
<p>&#x60A8;&#x7684;&#x5E94;&#x7528;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<a href="https://docs.flutter.io/flutter/services/AssetBundle-class.html" target="_blank"><code>AssetBundle</code></a>&#x5BF9;&#x8C61;&#x8BBF;&#x95EE;&#x5176;asset &#x3002;&#x6709;&#x4E24;&#x79CD;&#x4E3B;&#x8981;&#x65B9;&#x6CD5;&#x5141;&#x8BB8;&#x4ECE;Asset bundle&#x4E2D;&#x52A0;&#x8F7D;&#x5B57;&#x7B26;&#x4E32;&#x6216;&#x56FE;&#x7247;&#xFF08;&#x4E8C;&#x8FDB;&#x5236;&#xFF09;&#x6587;&#x4EF6;&#x3002;</p>
<h3 id="&#x52A0;&#x8F7D;&#x6587;&#x672C;assets">&#x52A0;&#x8F7D;&#x6587;&#x672C;assets</h3>
<ul>
<li>&#x901A;&#x8FC7;<a href="https://docs.flutter.io/flutter/services/rootBundle.html" target="_blank"><code>rootBundle</code></a> &#x5BF9;&#x8C61;&#x52A0;&#x8F7D;&#xFF1A;&#x6BCF;&#x4E2A;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x90FD;&#x6709;&#x4E00;&#x4E2A;<a href="https://docs.flutter.io/flutter/services/rootBundle.html" target="_blank"><code>rootBundle</code></a>&#x5BF9;&#x8C61;&#xFF0C; &#x901A;&#x8FC7;&#x5B83;&#x53EF;&#x4EE5;&#x8F7B;&#x677E;&#x8BBF;&#x95EE;&#x4E3B;&#x8D44;&#x6E90;&#x5305;&#xFF0C;&#x76F4;&#x63A5;&#x4F7F;&#x7528;<code>package:flutter/services.dart</code>&#x4E2D;&#x5168;&#x5C40;&#x9759;&#x6001;&#x7684;<code>rootBundle</code>&#x5BF9;&#x8C61;&#x6765;&#x52A0;&#x8F7D;asset&#x5373;&#x53EF;&#x3002;</li>
<li>&#x901A;&#x8FC7; <a href="https://docs.flutter.io/flutter/widgets/DefaultAssetBundle-class.html" target="_blank"><code>DefaultAssetBundle</code></a> &#x52A0;&#x8F7D;&#xFF1A;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528; <a href="https://docs.flutter.io/flutter/widgets/DefaultAssetBundle-class.html" target="_blank"><code>DefaultAssetBundle</code></a> &#x6765;&#x83B7;&#x53D6;&#x5F53;&#x524D;BuildContext&#x7684;AssetBundle&#x3002; &#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x4E0D;&#x662F;&#x4F7F;&#x7528;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6784;&#x5EFA;&#x7684;&#x9ED8;&#x8BA4;asset bundle&#xFF0C;&#x800C;&#x662F;&#x4F7F;&#x7236;&#x7EA7;widget&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x52A8;&#x6001;&#x66FF;&#x6362;&#x7684;&#x4E0D;&#x540C;&#x7684;AssetBundle&#xFF0C;&#x8FD9;&#x5BF9;&#x4E8E;&#x672C;&#x5730;&#x5316;&#x6216;&#x6D4B;&#x8BD5;&#x573A;&#x666F;&#x5F88;&#x6709;&#x7528;&#x3002;</li>
</ul>
<p>&#x901A;&#x5E38;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>DefaultAssetBundle.of()</code>&#x5728;&#x5E94;&#x7528;&#x8FD0;&#x884C;&#x65F6;&#x6765;&#x95F4;&#x63A5;&#x52A0;&#x8F7D;asset&#xFF08;&#x4F8B;&#x5982;JSON&#x6587;&#x4EF6;&#xFF09;&#xFF0C;&#x800C;&#x5728;widget&#x4E0A;&#x4E0B;&#x6587;&#x4E4B;&#x5916;&#xFF0C;&#x6216;&#x5176;&#x5B83;<code>AssetBundle</code>&#x53E5;&#x67C4;&#x4E0D;&#x53EF;&#x7528;&#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>rootBundle</code>&#x76F4;&#x63A5;&#x52A0;&#x8F7D;&#x8FD9;&#x4E9B;asset&#xFF0C;&#x4F8B;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">import</span> <span class="token string">&apos;dart:async&apos;</span> show Future<span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token string">&apos;package:flutter/services.dart&apos;</span> show rootBundle<span class="token punctuation">;</span>

Future<span class="token operator">&lt;</span>String<span class="token operator">&gt;</span> <span class="token function">loadAsset</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token keyword">async</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">await</span> rootBundle<span class="token punctuation">.</span><span class="token function">loadString</span><span class="token punctuation">(</span><span class="token string">&apos;assets/config.json&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x52A0;&#x8F7D;&#x56FE;&#x7247;">&#x52A0;&#x8F7D;&#x56FE;&#x7247;</h3>
<p>&#x7C7B;&#x4F3C;&#x4E8E;&#x539F;&#x751F;&#x5F00;&#x53D1;&#xFF0C;Flutter&#x4E5F;&#x53EF;&#x4EE5;&#x4E3A;&#x5F53;&#x524D;&#x8BBE;&#x5907;&#x52A0;&#x8F7D;&#x9002;&#x5408;&#x5176;&#x5206;&#x8FA8;&#x7387;&#x7684;&#x56FE;&#x50CF;&#x3002;</p>
<h4 id="&#x58F0;&#x660E;&#x5206;&#x8FA8;&#x7387;&#x76F8;&#x5173;&#x7684;&#x56FE;&#x7247;-assets">&#x58F0;&#x660E;&#x5206;&#x8FA8;&#x7387;&#x76F8;&#x5173;&#x7684;&#x56FE;&#x7247; assets</h4>
<p><a href="https://docs.flutter.io/flutter/painting/AssetImage-class.html" target="_blank"><code>AssetImage</code></a> &#x53EF;&#x4EE5;&#x5C06;asset&#x7684;&#x8BF7;&#x6C42;&#x903B;&#x8F91;&#x6620;&#x5C04;&#x5230;&#x6700;&#x63A5;&#x8FD1;&#x5F53;&#x524D;&#x8BBE;&#x5907;&#x50CF;&#x7D20;&#x6BD4;&#x4F8B;&#xFF08;dpi&#xFF09;&#x7684;asset&#x3002;&#x4E3A;&#x4E86;&#x4F7F;&#x8FD9;&#x79CD;&#x6620;&#x5C04;&#x8D77;&#x4F5C;&#x7528;&#xFF0C;&#x5FC5;&#x987B;&#x6839;&#x636E;&#x7279;&#x5B9A;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x6765;&#x4FDD;&#x5B58;asset&#xFF1A;</p>
<ul>
<li>&#x2026;/image.png</li>
<li>&#x2026;/<strong>M</strong>x/image.png</li>
<li>&#x2026;/<strong>N</strong>x/image.png</li>
<li>&#x2026;etc.</li>
</ul>
<p>&#x5176;&#x4E2D;M&#x548C;N&#x662F;&#x6570;&#x5B57;&#x6807;&#x8BC6;&#x7B26;&#xFF0C;&#x5BF9;&#x5E94;&#x4E8E;&#x5176;&#x4E2D;&#x5305;&#x542B;&#x7684;&#x56FE;&#x50CF;&#x7684;&#x5206;&#x8FA8;&#x7387;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x5B83;&#x4EEC;&#x6307;&#x5B9A;&#x4E0D;&#x540C;&#x8BBE;&#x5907;&#x50CF;&#x7D20;&#x6BD4;&#x4F8B;&#x7684;&#x56FE;&#x7247;&#x3002;</p>
<p>&#x4E3B;&#x8D44;&#x6E90;&#x9ED8;&#x8BA4;&#x5BF9;&#x5E94;&#x4E8E;1.0&#x500D;&#x7684;&#x5206;&#x8FA8;&#x7387;&#x56FE;&#x7247;&#x3002;&#x770B;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#xFF1A;</p>
<ul>
<li>&#x2026;/my_icon.png</li>
<li>&#x2026;/2.0x/my_icon.png</li>
<li>&#x2026;/3.0x/my_icon.png</li>
</ul>
<p>&#x5728;&#x8BBE;&#x5907;&#x50CF;&#x7D20;&#x6BD4;&#x7387;&#x4E3A;1.8&#x7684;&#x8BBE;&#x5907;&#x4E0A;&#xFF0C;<code>.../2.0x/my_icon.png</code> &#x5C06;&#x88AB;&#x9009;&#x62E9;&#x3002;&#x5BF9;&#x4E8E;2.7&#x7684;&#x8BBE;&#x5907;&#x50CF;&#x7D20;&#x6BD4;&#x7387;&#xFF0C;<code>.../3.0x/my_icon.png</code>&#x5C06;&#x88AB;&#x9009;&#x62E9;&#x3002;</p>
<p>&#x5982;&#x679C;&#x672A;&#x5728;<code>Image</code> widget&#x4E0A;&#x6307;&#x5B9A;&#x6E32;&#x67D3;&#x56FE;&#x50CF;&#x7684;&#x5BBD;&#x5EA6;&#x548C;&#x9AD8;&#x5EA6;&#xFF0C;&#x90A3;&#x4E48;<code>Image</code> widget&#x5C06;&#x5360;&#x7528;&#x4E0E;&#x4E3B;&#x8D44;&#x6E90;&#x76F8;&#x540C;&#x7684;&#x5C4F;&#x5E55;&#x7A7A;&#x95F4;&#x5927;&#x5C0F;&#x3002; &#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#xFF0C;&#x5982;&#x679C;<code>.../my_icon.png</code>&#x662F;72px&#x4E58;72px&#xFF0C;&#x90A3;&#x4E48;<code>.../3.0x/my_icon.png</code>&#x5E94;&#x8BE5;&#x662F;216px&#x4E58;216px; &#x4F46;&#x5982;&#x679C;&#x672A;&#x6307;&#x5B9A;&#x5BBD;&#x5EA6;&#x548C;&#x9AD8;&#x5EA6;&#xFF0C;&#x5B83;&#x4EEC;&#x90FD;&#x5C06;&#x6E32;&#x67D3;&#x4E3A;72&#x50CF;&#x7D20;&#xD7;72&#x50CF;&#x7D20;&#xFF08;&#x4EE5;&#x903B;&#x8F91;&#x50CF;&#x7D20;&#x4E3A;&#x5355;&#x4F4D;&#xFF09;&#x3002;</p>
<p><code>pubspec.yaml</code>&#x4E2D;asset&#x90E8;&#x5206;&#x4E2D;&#x7684;&#x6BCF;&#x4E00;&#x9879;&#x90FD;&#x5E94;&#x4E0E;&#x5B9E;&#x9645;&#x6587;&#x4EF6;&#x76F8;&#x5BF9;&#x5E94;&#xFF0C;&#x4F46;&#x4E3B;&#x8D44;&#x6E90;&#x9879;&#x9664;&#x5916;&#x3002;&#x5F53;&#x4E3B;&#x8D44;&#x6E90;&#x7F3A;&#x5C11;&#x67D0;&#x4E2A;&#x8D44;&#x6E90;&#x65F6;&#xFF0C;&#x4F1A;&#x6309;&#x5206;&#x8FA8;&#x7387;&#x4ECE;&#x4F4E;&#x5230;&#x9AD8;&#x7684;&#x987A;&#x5E8F;&#x53BB;&#x9009;&#x62E9; &#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;1x&#x4E2D;&#x6CA1;&#x6709;&#x7684;&#x8BDD;&#x4F1A;&#x5728;2x&#x4E2D;&#x627E;&#xFF0C;2x&#x4E2D;&#x8FD8;&#x6CA1;&#x6709;&#x7684;&#x8BDD;&#x5C31;&#x5728;3x&#x4E2D;&#x627E;&#x3002;</p>
<h4 id="&#x52A0;&#x8F7D;&#x56FE;&#x7247;">&#x52A0;&#x8F7D;&#x56FE;&#x7247;</h4>
<p>&#x8981;&#x52A0;&#x8F7D;&#x56FE;&#x7247;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <a href="https://docs.flutter.io/flutter/painting/AssetImage-class.html" target="_blank"><code>AssetImage</code></a>&#x7C7B;&#x3002;&#x4F8B;&#x5982;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4ECE;&#x4E0A;&#x9762;&#x7684;asset&#x58F0;&#x660E;&#x4E2D;&#x52A0;&#x8F7D;&#x80CC;&#x666F;&#x56FE;&#x7247;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">DecoratedBox</span><span class="token punctuation">(</span>
    decoration<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">BoxDecoration</span><span class="token punctuation">(</span>
      image<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">DecorationImage</span><span class="token punctuation">(</span>
        image<span class="token punctuation">:</span> <span class="token keyword">new</span> <span class="token class-name">AssetImage</span><span class="token punctuation">(</span><span class="token string">&apos;graphics/background.png&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;<code>AssetImage</code> &#x5E76;&#x975E;&#x662F;&#x4E00;&#x4E2A;widget&#xFF0C; &#x5B83;&#x5B9E;&#x9645;&#x4E0A;&#x662F;&#x4E00;&#x4E2A;<code>ImageProvider</code>&#xFF0C;&#x6709;&#x4E9B;&#x65F6;&#x5019;&#x4F60;&#x53EF;&#x80FD;&#x671F;&#x671B;&#x76F4;&#x63A5;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x663E;&#x793A;&#x56FE;&#x7247;&#x7684;widget&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>Image.asset()</code>&#x65B9;&#x6CD5;&#xFF0C;&#x5982;&#xFF1A;</p>
<pre class="language-"><code class="lang-dart">Widget <span class="token function">build</span><span class="token punctuation">(</span>BuildContext context<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> Image<span class="token punctuation">.</span><span class="token function">asset</span><span class="token punctuation">(</span><span class="token string">&apos;graphics/background.png&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x7684; asset bundle &#x52A0;&#x8F7D;&#x8D44;&#x6E90;&#x65F6;&#xFF0C;&#x5185;&#x90E8;&#x4F1A;&#x81EA;&#x52A8;&#x5904;&#x7406;&#x5206;&#x8FA8;&#x7387;&#x7B49;&#xFF0C;&#x8FD9;&#x4E9B;&#x5904;&#x7406;&#x5BF9;&#x5F00;&#x53D1;&#x8005;&#x6765;&#x8BF4;&#x662F;&#x65E0;&#x611F;&#x77E5;&#x7684;&#x3002; (&#x5982;&#x679C;&#x4F7F;&#x7528;&#x4E00;&#x4E9B;&#x66F4;&#x4F4E;&#x7EA7;&#x522B;&#x7684;&#x7C7B;&#xFF0C;&#x5982; <a href="https://docs.flutter.io/flutter/painting/ImageStream-class.html" target="_blank"><code>ImageStream</code></a>&#x6216; <a href="https://docs.flutter.io/flutter/painting/ImageCache-class.html" target="_blank"><code>ImageCache</code></a> &#x65F6;&#x4F60;&#x4F1A;&#x6CE8;&#x610F;&#x5230;&#x6709;&#x4E0E;&#x7F29;&#x653E;&#x76F8;&#x5173;&#x7684;&#x53C2;&#x6570;)</p>
<h4 id="&#x4F9D;&#x8D56;&#x5305;&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x56FE;&#x7247;">&#x4F9D;&#x8D56;&#x5305;&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x56FE;&#x7247;</h4>
<p>&#x8981;&#x52A0;&#x8F7D;&#x4F9D;&#x8D56;&#x5305;&#x4E2D;&#x7684;&#x56FE;&#x50CF;&#xFF0C;&#x5FC5;&#x987B;&#x7ED9;<code>AssetImage</code>&#x63D0;&#x4F9B;<code>package</code>&#x53C2;&#x6570;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x5047;&#x8BBE;&#x60A8;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4F9D;&#x8D56;&#x4E8E;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;&#x201C;my_icons&#x201D;&#x7684;&#x5305;&#xFF0C;&#x5B83;&#x5177;&#x6709;&#x5982;&#x4E0B;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF1A;</p>
<ul>
<li>&#x2026;/pubspec.yaml</li>
<li>&#x2026;/icons/heart.png</li>
<li>&#x2026;/icons/1.5x/heart.png</li>
<li>&#x2026;/icons/2.0x/heart.png</li>
<li>&#x2026;etc.</li>
</ul>
<p>&#x7136;&#x540E;&#x52A0;&#x8F7D;&#x56FE;&#x50CF;&#xFF0C;&#x4F7F;&#x7528;:</p>
<pre class="language-"><code class="lang-dart"> <span class="token keyword">new</span> <span class="token class-name">AssetImage</span><span class="token punctuation">(</span><span class="token string">&apos;icons/heart.png&apos;</span><span class="token punctuation">,</span> package<span class="token punctuation">:</span> <span class="token string">&apos;my_icons&apos;</span><span class="token punctuation">)</span>
</code></pre>
<p>&#x6216;</p>
<pre class="language-"><code class="lang-dart"><span class="token keyword">new</span> <span class="token class-name">Image<span class="token punctuation">.</span>asset</span><span class="token punctuation">(</span><span class="token string">&apos;icons/heart.png&apos;</span><span class="token punctuation">,</span> package<span class="token punctuation">:</span> <span class="token string">&apos;my_icons&apos;</span><span class="token punctuation">)</span>
</code></pre>
<p><strong>&#x6CE8;&#x610F;&#xFF1A;&#x5305;&#x5728;&#x4F7F;&#x7528;&#x672C;&#x8EAB;&#x7684;&#x8D44;&#x6E90;&#x65F6;&#x4E5F;&#x5E94;&#x8BE5;&#x52A0;&#x4E0A;<code>package</code>&#x53C2;&#x6570;&#x6765;&#x83B7;&#x53D6;</strong>&#x3002;</p>
<h5 id="&#x6253;&#x5305;&#x5305;&#x4E2D;&#x7684;-assets">&#x6253;&#x5305;&#x5305;&#x4E2D;&#x7684; assets</h5>
<p>&#x5982;&#x679C;&#x5728;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x4E2D;&#x58F0;&#x660E;&#x4E86;&#x671F;&#x671B;&#x7684;&#x8D44;&#x6E90;&#xFF0C;&#x5B83;&#x5C06;&#x4F1A;&#x6253;&#x5305;&#x5230;&#x76F8;&#x5E94;&#x7684;package&#x4E2D;&#x3002;&#x7279;&#x522B;&#x662F;&#xFF0C;&#x5305;&#x672C;&#x8EAB;&#x4F7F;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x5FC5;&#x987B;&#x5728;<code>pubspec.yaml</code>&#x4E2D;&#x6307;&#x5B9A;&#x3002;</p>
<p>&#x5305;&#x4E5F;&#x53EF;&#x4EE5;&#x9009;&#x62E9;&#x5728;&#x5176;<code>lib/</code>&#x6587;&#x4EF6;&#x5939;&#x4E2D;&#x5305;&#x542B;&#x672A;&#x5728;&#x5176;<code>pubspec.yaml</code>&#x6587;&#x4EF6;&#x4E2D;&#x58F0;&#x660E;&#x7684;&#x8D44;&#x6E90;&#x3002;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5BF9;&#x4E8E;&#x8981;&#x6253;&#x5305;&#x7684;&#x56FE;&#x7247;&#xFF0C;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5FC5;&#x987B;&#x5728;<code>pubspec.yaml</code>&#x4E2D;&#x6307;&#x5B9A;&#x5305;&#x542B;&#x54EA;&#x4E9B;&#x56FE;&#x50CF;&#x3002; &#x4F8B;&#x5982;&#xFF0C;&#x4E00;&#x4E2A;&#x540D;&#x4E3A;&#x201C;fancy_backgrounds&#x201D;&#x7684;&#x5305;&#xFF0C;&#x53EF;&#x80FD;&#x5305;&#x542B;&#x4EE5;&#x4E0B;&#x6587;&#x4EF6;&#xFF1A;</p>
<ul>
<li>&#x2026;/lib/backgrounds/background1.png</li>
<li>&#x2026;/lib/backgrounds/background2.png</li>
<li>&#x2026;/lib/backgrounds/background3.png</li>
</ul>
<p>&#x8981;&#x5305;&#x542B;&#x7B2C;&#x4E00;&#x5F20;&#x56FE;&#x50CF;&#xFF0C;&#x5FC5;&#x987B;&#x5728;<code>pubspec.yaml</code>&#x7684;assets&#x90E8;&#x5206;&#x4E2D;&#x58F0;&#x660E;&#x5B83;&#xFF1A;</p>
<pre class="language-"><code>flutter:
  assets:
    - packages/fancy_backgrounds/backgrounds/background1.png
</code></pre><p><code>lib/</code>&#x662F;&#x9690;&#x542B;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x5B83;&#x4E0D;&#x5E94;&#x8BE5;&#x5305;&#x542B;&#x5728;&#x8D44;&#x4EA7;&#x8DEF;&#x5F84;&#x4E2D;&#x3002;</p>
<h3 id="&#x7279;&#x5B9A;&#x5E73;&#x53F0;-assets">&#x7279;&#x5B9A;&#x5E73;&#x53F0; assets</h3>
<p>&#x4E0A;&#x9762;&#x7684;&#x8D44;&#x6E90;&#x90FD;&#x662F;flutter&#x5E94;&#x7528;&#x4E2D;&#x7684;&#xFF0C;&#x8FD9;&#x4E9B;&#x8D44;&#x6E90;&#x53EA;&#x6709;&#x5728;Flutter&#x6846;&#x67B6;&#x8FD0;&#x884C;&#x4E4B;&#x540E;&#x624D;&#x80FD;&#x4F7F;&#x7528;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x7ED9;&#x6211;&#x4EEC;&#x7684;&#x5E94;&#x7528;&#x8BBE;&#x7F6E;APP&#x56FE;&#x6807;&#x6216;&#x8005;&#x6DFB;&#x52A0;&#x542F;&#x52A8;&#x56FE;&#xFF0C;&#x90A3;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x4F7F;&#x7528;&#x7279;&#x5B9A;&#x5E73;&#x53F0;&#x7684;assets&#x3002;</p>
<h4 id="&#x8BBE;&#x7F6E;app&#x56FE;&#x6807;">&#x8BBE;&#x7F6E;APP&#x56FE;&#x6807;</h4>
<p>&#x66F4;&#x65B0;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x542F;&#x52A8;&#x56FE;&#x6807;&#x7684;&#x65B9;&#x5F0F;&#x4E0E;&#x5728;&#x672C;&#x673A;Android&#x6216;iOS&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x4E2D;&#x66F4;&#x65B0;&#x542F;&#x52A8;&#x56FE;&#x6807;&#x7684;&#x65B9;&#x5F0F;&#x76F8;&#x540C;&#x3002;</p>
<ul>
<li><p>Android</p>
<p>&#x5728;Flutter&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x4E2D;&#xFF0C;&#x5BFC;&#x822A;&#x5230;<code>.../android/app/src/main/res</code>&#x76EE;&#x5F55;&#xFF0C;&#x91CC;&#x9762;&#x5305;&#x542B;&#x4E86;&#x5404;&#x79CD;&#x8D44;&#x6E90;&#x6587;&#x4EF6;&#x5939;&#xFF08;&#x5982;<code>mipmap-hdpi</code>&#x5DF2;&#x5305;&#x542B;&#x5360;&#x4F4D;&#x7B26;&#x56FE;&#x50CF;&#x201C;ic_launcher.png&#x201D;&#xFF0C;&#x89C1;&#x56FE;2-8&#xFF09;&#x3002; &#x53EA;&#x9700;&#x6309;&#x7167;<a href="https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size" target="_blank">Android&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x6307;&#x5357;</a>&#x4E2D;&#x7684;&#x8BF4;&#x660E;&#xFF0C; &#x5C06;&#x5176;&#x66FF;&#x6362;&#x4E3A;&#x6240;&#x9700;&#x7684;&#x8D44;&#x6E90;&#xFF0C;&#x5E76;&#x9075;&#x5B88;&#x6BCF;&#x79CD;&#x5C4F;&#x5E55;&#x5BC6;&#x5EA6;&#xFF08;dpi&#xFF09;&#x7684;&#x5EFA;&#x8BAE;&#x56FE;&#x6807;&#x5927;&#x5C0F;&#x6807;&#x51C6;&#x3002;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/2-8.png" alt="&#x56FE;2-8"></p>
<blockquote>
<p><strong>&#x6CE8;&#x610F;:</strong> &#x5982;&#x679C;&#x60A8;&#x91CD;&#x547D;&#x540D;.png&#x6587;&#x4EF6;&#xFF0C;&#x5219;&#x8FD8;&#x5FC5;&#x987B;&#x5728;&#x60A8;<code>AndroidManifest.xml</code>&#x7684;<code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>application</span><span class="token punctuation">&gt;</span></span></code>&#x6807;&#x7B7E;&#x7684;<code>android:icon</code>&#x5C5E;&#x6027;&#x4E2D;&#x66F4;&#x65B0;&#x540D;&#x79F0;&#x3002;</p>
</blockquote>
</li>
<li><p>iOS</p>
<p>&#x5728;Flutter&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x4E2D;&#xFF0C;&#x5BFC;&#x822A;&#x5230;<code>.../ios/Runner</code>&#x3002;&#x8BE5;&#x76EE;&#x5F55;&#x4E2D;<code>Assets.xcassets/AppIcon.appiconset</code>&#x5DF2;&#x7ECF;&#x5305;&#x542B;&#x5360;&#x4F4D;&#x7B26;&#x56FE;&#x7247;&#xFF08;&#x89C1;&#x56FE;2-9&#xFF09;&#xFF0C; &#x53EA;&#x9700;&#x5C06;&#x5B83;&#x4EEC;&#x66FF;&#x6362;&#x4E3A;&#x9002;&#x5F53;&#x5927;&#x5C0F;&#x7684;&#x56FE;&#x7247;&#xFF0C;&#x4FDD;&#x7559;&#x539F;&#x59CB;&#x6587;&#x4EF6;&#x540D;&#x79F0;&#x3002;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/2-9.png" alt="&#x56FE;2-9"></p>
</li>
</ul>
<h4 id="&#x66F4;&#x65B0;&#x542F;&#x52A8;&#x9875;">&#x66F4;&#x65B0;&#x542F;&#x52A8;&#x9875;</h4>
<p><img src="https://pcdn.flutterchina.club/imgs/2-10.png" alt="&#x56FE;2-10"></p>
<p>&#x5728;Flutter&#x6846;&#x67B6;&#x52A0;&#x8F7D;&#x65F6;&#xFF0C;Flutter&#x4F1A;&#x4F7F;&#x7528;&#x672C;&#x5730;&#x5E73;&#x53F0;&#x673A;&#x5236;&#x7ED8;&#x5236;&#x542F;&#x52A8;&#x9875;&#x3002;&#x6B64;&#x542F;&#x52A8;&#x9875;&#x5C06;&#x6301;&#x7EED;&#x5230;Flutter&#x6E32;&#x67D3;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x7B2C;&#x4E00;&#x5E27;&#x65F6;&#x3002;</p>
<blockquote>
<p><strong>&#x6CE8;&#x610F;:</strong> &#x8FD9;&#x610F;&#x5473;&#x7740;&#x5982;&#x679C;&#x60A8;&#x4E0D;&#x5728;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;<code>main()</code>&#x65B9;&#x6CD5;&#x4E2D;&#x8C03;&#x7528;<a href="https://docs.flutter.io/flutter/widgets/runApp.html" target="_blank">runApp</a> &#x51FD;&#x6570; &#xFF08;&#x6216;&#x8005;&#x66F4;&#x5177;&#x4F53;&#x5730;&#x8BF4;&#xFF0C;&#x5982;&#x679C;&#x60A8;&#x4E0D;&#x8C03;&#x7528;<a href="https://docs.flutter.io/flutter/dart-ui/Window/render.html" target="_blank"><code>window.render</code></a>&#x53BB;&#x54CD;&#x5E94;<a href="https://docs.flutter.io/flutter/dart-ui/Window/onDrawFrame.html" target="_blank"><code>window.onDrawFrame</code></a>&#xFF09;&#x7684;&#x8BDD;&#xFF0C; &#x542F;&#x52A8;&#x5C4F;&#x5E55;&#x5C06;&#x6C38;&#x8FDC;&#x6301;&#x7EED;&#x663E;&#x793A;&#x3002;</p>
</blockquote>
<h5 id="android">Android</h5>
<p>&#x8981;&#x5C06;&#x542F;&#x52A8;&#x5C4F;&#x5E55;&#xFF08;splash screen&#xFF09;&#x6DFB;&#x52A0;&#x5230;&#x60A8;&#x7684;Flutter&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C; &#x8BF7;&#x5BFC;&#x822A;&#x81F3;<code>.../android/app/src/main</code>&#x3002;&#x5728;<code>res/drawable/launch_background.xml</code>&#xFF0C;&#x901A;&#x8FC7;&#x81EA;&#x5B9A;&#x4E49;drawable&#x6765;&#x5B9E;&#x73B0;&#x81EA;&#x5B9A;&#x4E49;&#x542F;&#x52A8;&#x754C;&#x9762;&#xFF08;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x6362;&#x4E00;&#x5F20;&#x56FE;&#x7247;&#xFF09;&#x3002;</p>
<h5 id="ios">iOS</h5>
<p>&#x8981;&#x5C06;&#x56FE;&#x7247;&#x6DFB;&#x52A0;&#x5230;&#x542F;&#x52A8;&#x5C4F;&#x5E55;&#xFF08;splash screen&#xFF09;&#x7684;&#x4E2D;&#x5FC3;&#xFF0C;&#x8BF7;&#x5BFC;&#x822A;&#x81F3;<code>.../ios/Runner</code>&#x3002;&#x5728;<code>Assets.xcassets/LaunchImage.imageset</code>&#xFF0C; &#x62D6;&#x5165;&#x56FE;&#x7247;&#xFF0C;&#x5E76;&#x547D;&#x540D;&#x4E3A;<code>LaunchImage.png</code>&#x3001;<code>LaunchImage@2x.png</code>&#x3001;<code>LaunchImage@3x.png</code>&#x3002; &#x5982;&#x679C;&#x4F60;&#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x6587;&#x4EF6;&#x540D;&#xFF0C;&#x90A3;&#x60A8;&#x8FD8;&#x5FC5;&#x987B;&#x66F4;&#x65B0;&#x540C;&#x4E00;&#x76EE;&#x5F55;&#x4E2D;&#x7684;<code>Contents.json</code>&#x6587;&#x4EF6;&#xFF0C;&#x56FE;&#x7247;&#x7684;&#x5177;&#x4F53;&#x5C3A;&#x5BF8;&#x53EF;&#x4EE5;&#x67E5;&#x770B;&#x82F9;&#x679C;&#x5B98;&#x65B9;&#x7684;&#x6807;&#x51C6;&#x3002;</p>
<p>&#x60A8;&#x4E5F;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x6253;&#x5F00;Xcode&#x5B8C;&#x5168;&#x81EA;&#x5B9A;&#x4E49;storyboard&#x3002;&#x5728;Project Navigator&#x4E2D;&#x5BFC;&#x822A;&#x5230;<code>Runner/Runner</code>&#x7136;&#x540E;&#x901A;&#x8FC7;&#x6253;&#x5F00;<code>Assets.xcassets</code>&#x62D6;&#x5165;&#x56FE;&#x7247;&#xFF0C;&#x6216;&#x8005;&#x901A;&#x8FC7;&#x5728;LaunchScreen.storyboard&#x4E2D;&#x4F7F;&#x7528;Interface Builder&#x8FDB;&#x884C;&#x81EA;&#x5B9A;&#x4E49;&#xFF0C;&#x5982;&#x56FE;2-11&#x6240;&#x793A;&#x3002;</p>
<p><img src="https://pcdn.flutterchina.club/imgs/2-11.png" alt="&#x56FE;2-11"></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="flutter_package_mgr.html" class="navigation navigation-prev " aria-label="Previous page: 2.3：包管理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="flutter_app_debug.html" class="navigation navigation-next " aria-label="Next page: 2.5：调试Flutter APP">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"2.4：资源管理","level":"2.2.4","depth":2,"next":{"title":"2.5：调试Flutter APP","level":"2.2.5","depth":2,"path":"chapter2/flutter_app_debug.md","ref":"chapter2/flutter_app_debug.md","articles":[]},"previous":{"title":"2.3：包管理","level":"2.2.3","depth":2,"path":"chapter2/flutter_package_mgr.md","ref":"chapter2/flutter_package_mgr.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-pro","ace","splitter","prism","donate","-highlight"],"root":"docs","styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"prism":{"lang":{"shell":"bash"}},"ace":{},"splitter":{},"search-pro":{"cutWordLib":"nodejieba","defineWord":["Gitbook Use"]},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"donate":{"alipay":"","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cdn.jsdelivr.net/gh/flutterchina/flutter-in-action@1.0.3/docs/imgs/pay.jpeg","wechatText":"微信打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"wendux 824783146@qq.com","bookRoot":"https://book.flutterchina.club/","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《Flutter实战》","language":"zh-hans","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"<div><img height=20 style='position:relative; top:5px; padding-right:5px ' src='https://cdn.jsdelivr.net/gh/flutterchina/website@1.0/images/favicon.png'/> Flutter中文网</div>":"https://flutterchina.club"}},"gitbook":"*","description":"记录Gitbook的配置和一些插件的使用"},"file":{"path":"chapter2/flutter_assets_mgr.md","mtime":"2019-08-20T04:26:30.829Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-15T14:52:22.710Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>



    <script src="https://pcdn.flutterchina.club/gitbook/gitbook.js"></script>
    <script src="https://pcdn.flutterchina.club/gitbook/theme.js"></script>
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-ace/ace.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="https://pcdn.flutterchina.club/gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    


<script src="https://pcdn.flutterchina.club/gitbook/pub.js"></script>
<script>
    hookAjax({
        open: function (arg, xhr) {
            if (location.hostname !== 'localhost') {
                if (arg[1][0] === '.') arg[1] = arg[1].slice(1);
                arg[1] = "https://pcdn.flutterchina.club" + arg[1].replace(".html", ".1")
            }
        },
        setRequestHeader: function (arg, xhr) {
            console.log(arg[0], arg[1]);
            if (arg[0] !== 'Accept') return true;
        },
        onload:function(){
            setTimeout(addAD);
        }
    })
</script>
</body>

</html>

